package com.example.opengldemo.ndk;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.os.Bundle;
import android.util.Log;


import androidx.appcompat.app.AppCompatActivity;

import com.example.opengldemo.R;

public class MyNDKActivity extends AppCompatActivity {
    final static String TAG = "MyNDKActivity" ;
    MyNDKView view ;
    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(deleteGLES()){
            view = new MyNDKView(this) ;
            setContentView(view);
        }
    }

    private boolean deleteGLES() {
        ActivityManager activityManager = (ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE) ;
        ConfigurationInfo deviceConfigurationInfo = activityManager.getDeviceConfigurationInfo();
        return deviceConfigurationInfo.reqGlEsVersion >=0x30000 ;
    }

    @Override
    protected void onPause() {
        super.onPause();
        if(view != null) view.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        if(view != null) view.onResume();
    }
}
